﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Things.ThingsWeb;

namespace Things.Web.Components
{
    public partial class TopSaledList : System.Web.UI.UserControl
    {
        protected Things.BLL.GoodsOrders goBll = new BLL.GoodsOrders();

        public Guid GoodsPriceID
        {
            get
            {
                string temp = hfGoodsPriceID.Value;
                Guid guid = Guid.Empty;
                if (Guid.TryParse(temp, out guid) == false)
                {
                    guid = Guid.Empty;
                }
                return guid;
            }
            set
            {
                hfGoodsPriceID.Value = value.ToString();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        public void BindData()
        {
            DataSet ds = new DataSet();
            ds = goBll.GetTopSaledList(10);
            gridView.DataSource = ds;
            gridView.DataBind();
        }

        protected string GetGoodsName(object obj)
        {
            string temp = obj != null ? obj.ToString() : string.Empty;
            string goodsName = PageUtility.GetLimitedString(temp, 25);
            if (string.IsNullOrEmpty(goodsName) == true)
            {
                goodsName = temp;
            }
            return goodsName;
        }
    }
}